"""
法人检查通知
"""
import pytest
from Config.Base import Base
from playwright.sync_api import Page, expect, Playwright
import allure
from Config.config import *
from Config.URL import *
import os
from Config.Base import Base
from Config.Tool import tool


@pytest.mark.业务系统
@pytest.mark.法人管理
def test_case(playwright : Playwright) -> None:
    SetupTeardown = Base(playwright)
    SetupTeardown.goto(url)
    SetupTeardown.login(username_admin, password_admin)
    context = SetupTeardown.context
    page = SetupTeardown.page
    

    page.goto("http://form.power-itech.cn:18004/#/projectLevel/sonGatewayHome/index")
    page.get_by_role("button", name=" 新建").click()
    page.get_by_placeholder("请输入标题").click()
    page.get_by_placeholder("请输入标题").fill("自动化法人检查通知")
    page.get_by_placeholder("请选择检查类型").click()
    page.locator("li").filter(has_text="年度检查").click()
    page.get_by_role("button", name="增加问题").click()
    page.get_by_role("row",
                     name="原材料（焊条、涂料、止水等）检验无记录或检验频次不够 原材料及设备检查验收 严重 管理员 2023-09-25 19:23").locator(
        "label span").nth(1).click()
    page.get_by_role("button", name="确 定").click()

    SetupTeardown.select_ssbd(bd_zhihuigu)
    # page.get_by_placeholder("请选择所属标段").click()
    # page.get_by_text(bd_zhihuigu).click()
    page.get_by_placeholder("请输入问题描述").fill("自动化法人检查通知-问题描述")
    page.locator("div").filter(has_text=re.compile(r"^问题照片加载失败$")).locator("i").click()
    with page.expect_file_chooser() as fc_info:
        page.locator(".normal > .el-upload").click()
    file_chooser = fc_info.value
    file_chooser.set_files(test_datas_dir + "\图片.jpg")
    allure.step("等待上传完成")
    page.wait_for_timeout(2000)
    page.get_by_placeholder("请输入整改要求").fill("自动化法人检查通知-整改要求")
    page.get_by_role("button", name="发起流程").click()





